#ifndef _MAINLOGIC_H
#define _MAINLOGIC_H


#include "ProcessList.h"
#include "Date.h"
#include "Event.h"
#include "Additional.h"
#include "FileStorage.h"
#include "Time.h"

#include <sstream>
#include <string>
#include <vector>
#include <ctime>
#include <fstream>
#include <stack>
#include <cassert>



using namespace std;

struct OutputText
{
	string statusMessage;
	string displayText;
};


enum COMMANDTYPE 
{	
	ADD=1, SHOW, DELETE, EDIT, DAY, LOCATION, TIME, UNDO, SFT, BY, DONE, PENDING, HISTORY, INVALID
};

class MainLogic
{
public:
	MainLogic();
	~MainLogic();

	void updateRecords();
	void processCommand( string );

	Date getCurrentSystemDate();
	string displayOutput();
	string getStatusMessage();


private:
	enum DISPLAYTYPE
	{
		PENDING=1,UPCOMING,OTHER
	};

	DISPLAYTYPE dtype;

	static const string invalidCommand;
	static const string successMessage;
	static const string errorShowCommand;

	void processTask( string ,COMMANDTYPE, struct Task&);

	string statusMessage;
	void updateDisplayList();
	void updatePendingList();

	string toLower(string);
	string removeFirstWord(string );
	string getFirstWord(string);
	vector<string> tokenizeCommand (string);

	bool isCommand (string);
	COMMANDTYPE getCommandType (string);
	bool equalsIgnoreCase(string str1, string str2);

	bool hasTodayOrTomorrowAsCommand (string);
	string updateIfTodayOrTomorrow(string);

	bool hasDeadlineWithTime(string command);
	string updateWithTimeRemoved (string);

	void setDetails (COMMANDTYPE,string, struct Task&);
	string trim(string);

	string getConvertedDate(string tempDate);
	bool isShowParameterValid(struct Task currentTask);

	string formatDisplayOutput();

	ProcessList processEvents;
	ProcessHistory processHistory;
	vector<Date> currentList;
	vector<Event> displayList;
	vector<Date> historyList;
	vector<Event> pendingList;
	string outputDisplay;
	
};

#endif